# PowerShell脚本用于启动后端服务并重定向日志
Set-Content -Path "logs\backend_startup.log" -Value "后端服务启动时间: $(Get-Date)"

# 启动后端服务并将输出重定向到日志文件
npm start 2>&1 | Tee-Object -FilePath "logs\backend.log"

if ($LASTEXITCODE -ne 0) {
    Add-Content -Path "logs\backend_startup.log" -Value "后端服务启动失败，错误代码: $LASTEXITCODE"
    Write-Host "后端服务启动失败，错误代码: $LASTEXITCODE"
} else {
    Add-Content -Path "logs\backend_startup.log" -Value "后端服务启动成功"
    Write-Host "后端服务启动成功"
}

Write-Host "按任意键退出..."
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")